package top.wangjiu.reactive.rpc.util;

import top.wangjiu.reactive.rpc.config.ClientConfiguration;
import top.wangjiu.reactive.rpc.config.ServiceConfig;
import top.wangjiu.reactive.rpc.proxy.RpcClientInvocationHandler;

import java.lang.reflect.Proxy;

public class RpcUtil {

    public static <T> T getRpcInstance(Class<T> interfaceClass, ServiceConfig config,ClientConfiguration configuration){
        RpcClientInvocationHandler handler = new RpcClientInvocationHandler(interfaceClass,config,configuration);
        return (T)Proxy.newProxyInstance(interfaceClass.getClassLoader(),new Class[]{interfaceClass},handler);
    }
}
